local thbattle__yaomeng_erdaoliu = fk.CreateSkill {

  name = "thbattle__yaomeng_erdaoliu",

  tags = { Skill.Compulsory, },

}

thbattle__yaomeng_erdaoliu:addAcquireEffect(function(self, player, is_start)
  local room = player.room
  room:addPlayerEquipSlots(player, { Player.WeaponSlot })
end)

thbattle__yaomeng_erdaoliu:addLoseEffect(function(self, player, is_start)
  local room = player.room
  if #table.filter(player.equipSlots,function (slot)
    return slot == Player.WeaponSlot
  end)>1 then
    room:removePlayerEquipSlots(player, { Player.WeaponSlot })
  end
end)

thbattle__yaomeng_erdaoliu:addEffect("targetmod", {
  residue_func = function(self, player, skill, scope, card, to)
    if player:hasSkill(thbattle__yaomeng_erdaoliu.name) and card and card.trueName == "slash" and #player:getCardIds("e") > 0
        and #table.filter(player:getCardIds("e"), function(cid)
          return Fk:getCardById(cid).sub_type == Card.SubtypeWeapon
        end) == 2 then
      return 1
    end
  end,
})

thbattle__yaomeng_erdaoliu:addEffect(fk.CardUsing, {
  mute=true,  
  can_trigger = function(self, event, target, player, data)
    local to = data.tos[1]
    return target == player and player:hasSkill(thbattle__yaomeng_erdaoliu.name) and
        data.card.trueName == "slash" and player:usedCardTimes("slash") > 1
  end,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("thbattle__yaomeng_erdaoliu")
    player.room:notifySkillInvoked(player, "thbattle__yaomeng_erdaoliu", "special", { player })
  end,
})

return thbattle__yaomeng_erdaoliu
